package com.ywy.bootadmin.task;

import com.ywy.bootadmin.service.sys.TaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 定时任务初始化
 *
 * @author ywy
 * @date 2021/11/3 16:39
 */
@Component
@Order(value = 1)
public class TaskInitializer implements CommandLineRunner {
    private static final Logger logger = LoggerFactory.getLogger(TaskInitializer.class);

    @Autowired
    private TaskService taskService;

    @Override
    public void run(String... args) throws Exception {
        try {
            taskService.initJob();
        } catch (Exception e) {
            e.printStackTrace();
        }

        logger.info("定时任务已加载完毕...");
    }
}
